<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021-3-6
 * Time: 20:04
 */

namespace app\admin\controller;


use app\admin\model\System;
use think\Db;

class Systemset extends Base
{
    public function index()
    {
        $sys = System::get(1);
        $this->assign('sys', $sys);
        return $this->fetch('index/systemset');
    }

    public function save()
    {
        Db::startTrans();
        try {
            $sys = System::get(1);
            $sys->save($_POST);
            Db::commit();
        } catch (\Exception $e) {
            Db::rollback();
            $this->error('系统信息更新失败！<br>Error：' . $e->getMessage());
        }
        $this->success('系统信息更新成功！');
    }

    public function sendMail($receive_mail)
    {
        $rs = send_mail($receive_mail);
        if (!$rs['code']) {
            $this->error($rs['msg']);
        }
        $this->success($rs['msg']);
    }
}